<?php
include('common.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>安装</title>
<style>
*{
	margin:0;
	padding:0;	
}
body{
	font-size:14px;
	color:#000;	
}
#container{
	width:800px;
	border:1px solid #ccc;
	margin:0 auto;
	padding:20px;	
}
#object_1,#object_2{
	display:none;	
}
#get_info{
	width:400px;
	height:200px;
	overflow:scroll;
	margin:0 auto;	
}
#phpinfo{
	height:300px;
	overflow:scroll;	
}
</style>
<script src="jquery.js"></script>
<script>
$(document).ready(function(e) {
	$('#type_1').click(function(){
		$('#object_1').show();
		$('#object_2').hide();	
	});
	$('#type_2').click(function(){
		$('#object_2').show();
		$('#object_1').hide();
	});
    $('#type_1').click();
	$('#test').click(function(){
		var host=$('#host').val();
		var user_name=$('#user_name').val();
		var user_pwd=$('#user_pwd').val();
		var db_name=$('#db_name').val();
		$.post('action.php?a=test',{'host':host,'user_name':user_name,'user_pwd':user_pwd,'db_name':db_name},function(data){
			$('#get_info').html(data.msg);
		},'json');
	});
	
	$('#install').click(function(){
		var host=$('#host').val();
		var user_name=$('#user_name').val();
		var user_pwd=$('#user_pwd').val();
		var db_name=$('#db_name').val();
		
		var type=$("input[name='type']:checked").val();
		var data=$('#data').val();
		var file=$('#file').val();
		
		
		$.post('action.php?a=install',{'host':host,'user_name':user_name,'user_pwd':user_pwd,'db_name':db_name,'type':type,'data':data,'file':file},function(data){
			$('#get_info').html(data.msg);
		},'json');
	});
	
	
	$('#config').click(function(){
		var host=$('#host').val();
		var user_name=$('#user_name').val();
		var user_pwd=$('#user_pwd').val();
		var db_name=$('#db_name').val();
		var db_pre=$('#db_pre').val();
		var url=$('#url').val();
		var cookie_domain=$('#cookie_domain').val();
		
		$.post('action.php?a=config',{'host':host,'user_name':user_name,'user_pwd':user_pwd,'db_name':db_name,'db_pre':db_pre,'url':url,'cookie_domain':cookie_domain},function(data){
			$('#get_info').html(data.msg);
		},'json');
	});
});
</script>
</head>
<body>
<br />
<br />
<br />
<br />

<div id="container">
<h1>安装</h1>

<table width="100%" border="1" cellspacing="2" cellpadding="2">
  <tr>
    <th align="right" scope="row">主机：</th>
    <td align="left"><input type="text" name="host" id="host" value="localhost" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">账号：</th>
    <td align="left"><input type="text" name="user_name" id="user_name" value="" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">密码：</th>
    <td align="left"><input type="text" name="user_pwd" id="user_pwd" value="" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">数据库：</th>
    <td align="left"><input type="text" name="db_name" id="db_name" value="" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">表前缀：</th>
    <td align="left"><input type="text" name="db_pre" id="db_pre" value="" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">&nbsp;</th>
    <td align="left"><input type="button" id="test" value="测试连接" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">数据安装方式：</th>
    <td align="left">
      <label><input type="radio" name="type" value="1" id="type_1" />文本框</label>
      <label><input type="radio" name="type" value="2" id="type_2" />文件名</label>
	</td>
  </tr>
  <tr id="object_1">
    <th align="right" scope="row">数据：</th>
    <td align="left"><textarea name="data" id="data" rows="4" cols="50"></textarea></td>
  </tr>
  <tr id="object_2">
    <th align="right" scope="row">文件名：</th>
    <td align="left"><input type="text" name="file" id="file" value="localhost.sql" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">域名：</th>
    <td align="left"><input type="text" name="url" id="url" value="http://www.cms.com/" /></td>
  </tr>
  <tr>
    <th align="right" scope="row">cookie作用域：</th>
    <td align="left"><input type="text" name="cookie_domain" id="cookie_domain" value=".cms.com" /></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input type="button" id="install" value="安装" /></td>
  </tr>
  <tr>
    <td colspan="2" align="center"><input type="button" id="config" value="生成配置文件" /></td>
    </tr>
</table>


</div>
<div id="get_info">

</div>

<div id="phpinfo">
<a target="_blank" href="phpinfo.php">phpinfo</a>
</div>
</body>
</html>